package com.qianxun.module.datasource1.develop.manager;

import com.qianxun.module.datasource1.develop.mapper.SysFunctionRoleRelationMapper;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: huwei
 * @date: 2019/12/3 9:26
 * @version: 1.0.0
 */
@Component
@CacheConfig(cacheNames = {"function_role_relation"})
public class SysFunctionRoleRelationCacheManager {
    @Resource
    private SysFunctionRoleRelationMapper sysFunctionRoleRelationMapper;

    @Cacheable(key = "#root.targetClass + #root.methodName + #functionId")
    public List<String> listFunctionNameByFunctionId(long functionId) {
        return sysFunctionRoleRelationMapper.selectFunctionNameByFunctionId(functionId);
    }

    @CacheEvict(allEntries = true)
    public void removeByFunctionRoleId(int functionRoleId){
        sysFunctionRoleRelationMapper.deleteByFunctionRoleId(functionRoleId);
    }
}
